import axios from "axios";
import qs from "qs";
// axios.defaults.baseURL = 'https://api.jiudaifu.com/v3/'
axios.defaults.baseURL = process.env.NODE_ENV == 'development' ? '' : "https://api.jiudaifu.com/v3/"
//舌照上传，添加请求头
const config = {
  headers: {
    "Content-Type": "multipart/form-data",
  },
};
// 上传舌诊图片
export const tongUp = (params) => {
  return axios.post(`/api/tongueImageUpload`, params, config);
};

// 上报舌诊信息
export const tongReport = (params) => {
  return axios.post(`/api/reportTongue`, params, config);
};

// 获取舌诊记录列表
export const tongueReportList = (params) => {
  return axios.get(`/api/tongueReportList`, { params });
};

//舌诊报告进一步生成报告诊断 
export const furtherTongueReport = params =>{ return axios.get(`/api/furtherTongueReport`, { params } )};

// 获取调理方案标题
export const nameCare = params =>{ return axios.get(`/api/getSchemeWithVisceral`, { params } )};

// 根据方案名获取调理方案详情
export const nameCare_detail = params =>{ return axios.get(`/api/schemeDetail`, { params } )};

// 根据病症名获取调理方案详情
export const getSchemeWithSymptom = params =>{ return axios.get(`/api/getSchemeWithSymptom`, { params } )};

//get,post请求封装
export function post(url, params) {
  return new Promise((resolve, reject) => {
    axios
      .post(url, qs.stringify(params))
      .then((res) => {
        resolve(res.data);
      })
      .catch((err) => {
        reject(err.data);
      });
  });
}
export function get(url, params) {
  return new Promise((resolve, reject) => {
    axios
      .get(url, {
        params: params,
      })
      .then((res) => {
        resolve(res.data);
      })
      .catch((err) => {
        reject(err.data);
      });
  });
}
